/*
 * @Description:
 * @Version: 2.0
 * @Autor: wiz
 * @Date: 2024-04-19 09:40:39
 * @LastEditors: wiz
 * @LastEditTime: 2024-04-19 13:29:10
 */
export class T_lockInfo {
  // funID:keys
  private d: Map<
    string,
    Array<{
      funID: string;
      rowID: string;
      key: string;
    }>
  > = new Map();

  public getLockInfo(): Map<
    string,
    Array<{
      funID: string;
      rowID: string;
      key: string;
    }>
  > {
    return this.d;
  }

  public getLockInfoByfunID(
    funID: string
  ): {
    d: Array<{
      funID: string;
      rowID: string;
      key: string;
    }>;
    ok: boolean;
  } {
    if (this.d.has(funID)) {
      return { d: this.d.get(funID), ok: true };
    }
    return { d: [], ok: false };
  }

  public add(p: { funID: string; rowID: string; key: string }) {
    if (this.d.has(p.funID)) {
      this.d.get(p.funID).push(p);
    } else {
      this.d.set(p.funID, [p]);
    }
  }

  public cleanLockInfo() {
    this.d.clear();
  }

  public removeLockInfoByFunID(funID: string) {
    this.d.delete(funID);
  }
}
export interface I_lockInfo extends T_lockInfo {}
